import { http } from '@/utils/http/axios';

export function getApps(params) {
  return http.request({
    url: import.meta.env.VITE_GLOB_API_URL + '/apps',
    method: 'GET',
    params,
  });
}

export function uploadFile(data) {
  return http.uploadFile(
    {
      url: import.meta.env.VITE_GLOB_API_URL + '/apps/upload',
    },
    data
  );
}

export function appPreview(code) {
  return http.request({
    url: import.meta.env.VITE_GLOB_API_URL + '/apps/preview/' + code,
    method: 'GET',
  });
}

export function getPackages(params) {
  return http.request({
    url: import.meta.env.VITE_GLOB_API_URL + '/apps/packages/' + params.shortCode,
    method: 'GET',
    params,
  });
}

export function deleteApp(id) {
  return http.request({
    url: import.meta.env.VITE_GLOB_API_URL + '/apps/delete/' + id,
    method: 'DELETE',
  });
}

export function deletePackage(id) {
  return http.request({
    url: import.meta.env.VITE_GLOB_API_URL + '/package/delete/' + id,
    method: 'DELETE',
  });
}

export function updateApp(params) {
  return http.request({
    url: import.meta.env.VITE_GLOB_API_URL + '/apps',
    method: 'PUT',
    params,
  });
}
